package cn.doitedu.javase.io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class _01_FileOutputStream_基本API {

    public static void main(String[] args) throws IOException {

        String content1 = "i love you \n";
        String content2 = "i study in doe school";

        // 构造一个文件字节输出流
        FileOutputStream fileOutputStream = new FileOutputStream("E:/b.txt",false);

        // 现将要写入的数据转成字节数组
        byte[] bytes1 = content1.getBytes(StandardCharsets.UTF_8);
        byte[] bytes2 = content2.getBytes(StandardCharsets.UTF_8);

        // 然后调用outputStream.write方法来输出这个字节数组
        fileOutputStream.write(bytes1);
        fileOutputStream.write(bytes2);

        // 关闭输出流
        fileOutputStream.close();


    }
}
